import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import './assets/scss/reset.scss'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import http from './assets/api/config'
import './mock'
Vue.config.productionTip = false;
Vue.use(ElementUI);
Vue.prototype.$http = http

router.beforeEach(function(to, from, next) {
  store.commit('getToken')
  let token = store.state.user.token
  if (!token && to.name !== 'Login') {
    next({ name: 'Login' })
  } else { 
    next()
  }
})

new Vue({
  router,
  store,
  render: (h) => h(App),
  //操作实例化
  created() { 
    store.commit('addMenu',router)
  }
}).$mount("#app");
